home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr47 / wasm223.zip / SERIAL9.ASM < prev    next >
Assembly Source File  |  1993-05-04  |  1KB  |  49 lines

  1. ;********************************;
  2. ; WASM Serial I/O, Replacement   ;
  3. ; By Eric Tauck                  ;
  4. ;                                ;
  5. ; Defines:                       ;
  6. ;                                ;
  7. ;   ComRep  replace a byte       ;
  8. ;                                ;
  9. ; Requires:                      ;
  10. ;                                ;
  11. ;   SERIAL1.ASM                  ;
  12. ;********************************;
  13.  
  14.         jmps    _serial9_end
  15.  
  16. ;========================================
  17. ; Replace an input byte.
  18. ;
  19. ; In: AL= byte; BX= serial record.
  20.  
  21. ComRep  PROC    NEAR
  22.         push    di
  23.         push    es
  24.  
  25. ;--- store byte
  26.  
  27.         les     di, [bx + _COM_BUFPTR2] ;buffer read address
  28.         cmp     di, [bx + _COM_BUFBEG]  ;check if at beginning
  29.         jne     _cmrep1
  30.         mov     di, [bx + _COM_BUFEND]  ;wrap to end
  31. _cmrep1 dec     di                      ;decrement pointer
  32.         seg     es
  33.         mov     [di], al                ;save byte
  34.         mov     [bx + _COM_BUFPTR2], di ;save pointer
  35.  
  36. ;--- update bytes in buffer
  37.  
  38.         mov     ax, [bx + _COM_BUFBYTE] ;load byte count
  39.         cmp     ax, [bx + _COM_BUFSIZE] ;compare to size
  40.         je      _cmrep2                 ;skip increment if full
  41.         inc     WORD [bx+_COM_BUFBYTE]  ;increment bytes
  42.  
  43. _cmrep2 pop     es
  44.         pop     di
  45.         ret
  46.         ENDP
  47.  
  48. _serial9_end
  49.